package com.swf.seed.txt.file;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import com.swf.common.utils.FwsIOUtils;

public class FileWriter extends Thread {
	private long begin;
	private static int counter  = 100000;
	private static List lc  = new ArrayList();
	public static void main(String[] args) throws IOException {
		ExecutorService t = Executors.newFixedThreadPool(100);
		for (int i=0;i<10000;i++){
			FileWriter fw = new FileWriter(i);
			t.execute(fw);
		}
		t.shutdown();
	}
	
	public FileWriter(long begin) {
		this.begin = begin;
	}
	@Override
	public void run() {
		FwsIOUtils io = FwsIOUtils.getInstance();
		io.setAppend(false);
		io.setCharst("GBK");
		io.setOutPath("d:/a/c/"+begin+".txt");
		System.out.println("d:/a/c/"+begin+".txt");
		StringBuffer sb = new StringBuffer();
		for (int i=(int) begin*counter;i<begin*counter+counter;i++){
			sb.append(i).append("\n");
		}
		io.setContent(sb.toString());
		try {
			io.writeByline();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
